from wxpita import *

f = SizedFrame [
    Button(name='btn1', label='Button 1'),
    Button(name='btn2', label='Button 2'),
    ListBox(name='lb1', expand=True, proportion=1),
    ListBox(name='lb2'),
]

def onclick(evt):
    print 'You clicked', evt.EventObject.GetLabel()

def onselected(evt):
    print 'You selected item %d' % evt.EventObject.GetSelection()

@f.Init
def _():
    for i in range(7890, 7987):
        f.lb1.Append(unichr(i))

    for i in range(14040, 14120):
        f.lb2.Append(unichr(i))
    
    f.btn1.Connect(wx.ID_ANY, wx.ID_ANY,
                  wx.wxEVT_COMMAND_BUTTON_CLICKED, onclick)

    f.btn2.Connect(wx.ID_ANY, wx.ID_ANY,
                  wx.EVT_BUTTON.evtType[0], onclick)

    f.lb1.Connect(wx.ID_ANY, wx.ID_ANY,
                  wx.wxEVT_COMMAND_LISTBOX_SELECTED, onselected)
    
    f.Fit()

f.Show('Event binding using the Connect method')
